package com.lagou.utils;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

/**
 * desc: 解析获取properties文件
 *
 * @author tengfei wang
 * @version 1.0
 * @date Created in 8/9/2020
 */
public class PropertyUtil {

    private static final Properties PROPERTIES = new Properties();

    public static final String MARK = ",";

    static {
        InputStream inputStream = PropertyUtil.class.getClassLoader().getResourceAsStream("springConfig.properties");
        try {
            PROPERTIES.load(inputStream);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public static Properties getProperties() {
        return PROPERTIES;
    }

    public static String getProperty(String name) {
        return PROPERTIES.getProperty(name);
    }

    public static String[] getBasePackage() {
        String property = PROPERTIES.getProperty("base.package");
        if (property.contains(MARK)) {
            return property.split(MARK);
        }
        return new String[]{property};
    }


}
